package com.shop.dao.implement;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.shop.dao.HibernateBaseDao;
import com.shop.dao.IAdminDao;
import com.shop.pojo.Admin;

public class AdminDao extends HibernateBaseDao<Admin> implements IAdminDao {
	@SuppressWarnings("unchecked")
	public int count(int level) {
		String hql="select count(*) from Admin a where a.level>:level";
		Map map =new  HashMap();
		map.put("level", level);
		return ((Long)find(hql, map)).intValue();
	}
	@SuppressWarnings("unchecked")
	public List<Admin> find(int level,int firstResult,int maxResult) {
		String hql="from Admin a where a.level>:level";
		return findByHql(hql, "level", level, firstResult, maxResult, null);
	}
	@SuppressWarnings("unchecked")
	public Admin findByUserName(String userName){
		String hql="from Admin a where a.username=:userName";
		Map map =new  HashMap();
		map.put("userName", userName);
		return (Admin)find(hql, map);
	}


}
